//
//  PlantCell.m
//  植物管理
//
//  Created by liujianlong on 2022/11/21.
//

#import "PlantCell.h"

@interface PlantCell()
@property (strong, nonatomic) IBOutlet UILabel *title;
@property (strong, nonatomic) IBOutlet UILabel *date;
@property (strong, nonatomic) IBOutlet UIImageView *img;
@property (strong, nonatomic) IBOutlet UILabel *content;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *imgH;

@end
@implementation PlantCell

- (void)awakeFromNib {
    [super awakeFromNib];
    CGFloat w = (SCREEN_WIDTH - 60) / 2;
    CGRect bounds = CGRectMake(0, 0, w, 212 / 158.0 * w);
    self.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight | UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)].CGPath;
    self.layer.shadowColor = @"#E8F1EC".color.CGColor;
    self.layer.shadowOffset = CGSizeMake(0, 0);
    self.layer.cornerRadius = 20;
    self.layer.shadowRadius = 10;
    self.layer.shadowOpacity = 1;
}
- (void)setModel:(Plant *)model{
    _model = model;
    self.imgH.constant = model.imgs.count  > 0 ? 117 : 0;
    self.title.text = model.name;
    self.content.text = model.content;
    self.img.image = model.imgs.count > 0 ? [UIImage imageWithData:model.imgs[0]] : nil;
    self.date.text = [NSDate transToDate:@"yyyy.MM.dd" :model.stamp];
}
@end
